(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/js/helloSceneScript.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '643efy4A9hNtqChBfPo+7Ut', 'helloSceneScript', __filename);
// js/helloSceneScript.js

"use strict";

cc.Class({
    extends: cc.Component,

    properties: {
        getBtnGroup: [cc.Node],
        getHomeView: cc.Node,
        getRoleSelectView: [cc.Node],
        getRolesPrefab: cc.Prefab,
        getRolesScrollContent: cc.Node
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function onLoad() {
        //场景预加载
        cc.director.preloadScene("play", function () {
            cc.log("预加载成功");
        });
        //加载按钮组
        this.BtnGroupFade(true);

        //禁用按钮（若要根据获取的数据进行配置则需要在此配置，如果时永久性禁用，可在cocos编辑器中直接设置）
        //this.getBtnGroup[3].getComponent(cc.Button).interactable=false;

        //角色预制体加载
        for (var i = 0; i < 10; i++) {
            var rolePrefab = cc.instantiate(this.getRolesPrefab); //实例化1个预制体
            this.getRolesScrollContent.addChild(rolePrefab); //将其赋予content节点(创建子节点)
            var prefabStyleJs = rolePrefab.getComponent('rolesPrefab'); //调用预制体的js组件
            prefabStyleJs.setPrefabStyle(i); //执行预制体JS中的样式设置函数，传入参数i
            prefabStyleJs.roleChengePrefab(i); //执行预制体JS中的角色切换函数，传入参数i
        }
    },


    //点击按钮切换场景
    btnJdClick: function btnJdClick() {
        //延迟加载场景
        this.BtnGroupFade(false);
        setTimeout(function () {
            cc.director.loadScene("play");
        }, 600);
    },


    //按钮淡入淡出
    BtnGroupFade: function BtnGroupFade(isLoad) {
        var arr = this.getBtnGroup;
        for (var i = 0; i < arr.length; i++) {
            if (isLoad) {
                arr[i].runAction(cc.fadeTo(0, 0)); //加载前将其设置透明
                var delayTime = cc.delayTime(0.1 * i); //延迟时间以实现淡入间隔
                var moveTo = cc.moveTo(.3, cc.v2(arr[i].x - 250, arr[i].y));
                var fadeIn = cc.fadeIn(.3);
                var action = cc.spawn(moveTo, fadeIn); //同步执行渐显和移动
            } else {
                var delayTime = cc.delayTime((3 - i) * 0.1); //延迟时间以实现淡入间隔（反向）
                var moveTo = cc.moveTo(.3, cc.v2(arr[i].x + 250, arr[i].y));
                var fadeOut = cc.fadeOut(.3);
                var action = cc.spawn(moveTo, fadeOut); //同步执行渐隐和移动
            }
            var seq = cc.sequence(delayTime, action); //依次执行
            seq.setTag(1); //设置动作的标签
            arr[i].runAction(seq);
        }
    },


    //打开or关闭角色选择窗口
    showRoleSelectView: function showRoleSelectView(e, data) {
        if (data == 'open') {
            if (this.getBtnGroup[3].getActionByTag(1)) {
                //判断节点是否正在执行动作
                return;
            }
            this.getHomeView.active = false;
            this.BtnGroupFade(false);
            this.roleSelectViewFade(true);
        } else {
            this.roleSelectViewFade(false);
            this.getHomeView.active = true;
            this.BtnGroupFade(true);
        }
    },


    //角色窗口渐显
    roleSelectViewFade: function roleSelectViewFade(isShow) {
        var arr2 = this.getRoleSelectView;
        for (var i = 0; i < arr2.length; i++) {
            if (isShow) {
                var delayTime = cc.delayTime(0.3 * i); //延迟时间以实现淡入间隔
                var moveTo = cc.moveTo(.3, cc.v2(arr2[i].x, arr2[i].y - 290));
                var fadeIn = cc.fadeIn(.3);
                var action = cc.spawn(moveTo, fadeIn); //同步执行渐显和移动
                var seq = cc.sequence(delayTime, action); //依次执行
            } else {
                this.getRoleSelectView.active = false;
                var seq = cc.moveTo(0, cc.v2(arr2[i].x, arr2[i].y + 290));
            }
            arr2[i].runAction(seq);
        }
    }

    /* start () {}, */

    // update (dt) {},

});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=helloSceneScript.js.map
        